package com.foreknow.demo5;

import java.util.Scanner;

public class EmployeeManager {
    private int count;
    private Employee[] array;//定义一个属性类型

    public Employee[] getArray() {
        return array;
    }

    public void setArray(Employee[] array) {
        this.array = array;
    }

    public EmployeeManager(){// 用构造器初始化
        this.array = new Employee[10];
    }

    public void join(Employee a) {//向数组添加元素
        if (a != null) {
            if (count < 5) {
                array[count] = a;
                count++;
                System.out.println("添加成功");
            }
        }
    }
    public Employee[] query(){//查询所有员工信息
        Employee[] a = new Employee[10];
        for (int i = 0;i < a.length;i++){
            a[i] = array[i];
        }
        return a;
    }

    public Employee queryId(String id){//根据id查询员工信息
            Employee employee = new Employee();
        for (int i = 0;i<array.length;i++){
            String sid = array[i].getId();
            if (id.equals(sid)){
                array[i] = employee;
            }else {
                System.out.println("没有这个人");
            }
        }
        return employee;
    }

    public static void main(String[] args) {

    }

}
